/*
 * meter.h
 *
 *  Created on: 2018-3-31
 *      Author: root
 */

#ifndef METER_H_
#define METER_H_
#include "share_type.h"
#include "protocol_meter.h"
#define DC           1
#define AC           2
#define ttyS0  0
#define ttyS1  1
#define ttyS2  2
#define ttyS3  3
#define ttyS4  4
#define ttyS5  5
#define MaxV   2640
#define MinV   1760
#define MaxI   35200
#define overV      0x01   // 过压
#define lowV       0x02   //欠压
#define overI      0x04   //过流
#define OVERTIME   30000//5min  60*5*1000
#define FAILREAD_TIME  15000//20秒
#define GUN_NUM 8
typedef enum
{
	   DCA210=1,
	   DCA600 =2,//
	   DCA700 =3,//


}TCU_Type;

typedef struct
{
	u8 Vover_counter[3];
  u8 Vlow_counter[3];
	u8 Iover_counter[3];
}MT_OVER_COUNTER;
typedef struct
{
	int Vover_time[3];
   int Vlow_time[3];
	int Iover_time[3];
}MT_OVER_TIME;
typedef struct
{
	char addr[6];
  u8 ctrl;
  u8 lenData;
  u8 data[32];
}Meter_645;
//typedef enum
//{
//	   METER_OUT_1=0,//1枪输出电表
//	   METER_OUT_2=1,//2枪输出电表
//	   METER_OUT_3=2,//3枪输出电表
//	   METER_OUT_4=3,//4枪输出电表
//	   METER_OUT_5=4,//5枪输出电表
//	   METER_OUT_6=5,//6枪输出电表
//	   METER_OUT_7=6,//7枪输出电表
//	   METER_OUT_8=7,//8枪输出电表
//	   METER_IN=8,//输入电表
//
//
//}MT_TYPE;
#define MTNUM   GUN_NUM+1
#define METER_IN  GUN_NUM

extern u8 notRead_Num[];
extern uart_meter gp_mt;
void Uart_Meter_Init(u8 portid,unsigned int baud);
int getMtAddr(u8 portid,u8 gunid,char* addr);
//u8 ReadMeterData(u8 gunnum,char* addr,uart_meter *gp_mt);
int ReadMeterData(u8 port,u8 gunid,char* addr,char phase_num,int ct);
void addtime_meter1000(int interval);
#endif /* METER_H_ */
